﻿using MediatR;
using MES.Server.API.Application.Command.Process_Procedures.ProcessFlow;
using MES.Server.API.Dto.ProcessProceduresDTO;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ReturnValue;

namespace MES.Server.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ProcessFlowController : ControllerBase
    {
        private readonly IMediator mediator;
        public ProcessFlowController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取工艺流程
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public Task<ApiPaging<ProcessFlowDTO>> GetProcessFlows([FromQuery]GetProcessFlowCommand request)
        {
            return  mediator.Send(request);
        }
        /// <summary>
        /// 添加工艺流程
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public Task<ApiResult<int>> AddProcessFlows(AddProcessFlowCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 删除工艺流程
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpDelete]
        public Task<ApiResult<int>> DelProcessFlows([FromQuery]DelProcessFlowCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 查看工艺详情
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpGet]
        public  Task<ApiResult<ProcessFlowDetailDto>> CheckProcessFlows([FromQuery]CheckProcessFlowCommand request)
        {
            return mediator.Send(request);
        }
    }
}
